#!/bin/sh
#
# C language lint checking, mainly for use in PCP CI builds.
# Usage: scripts/c-lint -I$(TOPDIR)/src/include/pcp <file>...
#
# Note: silently exits if 'cppcheck' utility is unavailable.
#

which cppcheck >/dev/null 2>&1
[ $? -eq 0 ] || exit 0	# not installed

args="--inline-suppr --force --quiet --error-exitcode=1"

if cppcheck --help | grep -- --library >/dev/null
then
    args="$args --library=posix"
else
    args="$args --std=posix"
fi

if test `uname -s` = Linux
then
    args="$args -I/usr/include/bits"
fi

exec cppcheck $args "$@"
